<?php


namespace api\web\validate;

use think\Validate;

class SpuValidate extends Validate
{
    //定义验证规则
    protected $rule = [
        'name' => 'require|max:30|min:1',
        'image' => 'require',
//        'look_num' => 'require|integer',
        'zy' => 'require',
//        'author' => 'require',
        'id' => 'require'
    ];

    //定义验证失败时的提示信息
    protected $message = [
        'name.require' => '标题不能为空',
        'name.max:30' => '标题最大不能超过30个文字',
        'name.min:1' => '标题不能小于一个字',
        'image.require' => '图片不能为空',
//        'look_num.require' => '浏览量不能为空',
//        'look_num.integer' => '浏览量必须是整数',
        'zy.require' => '自营不能为空',
//        'author.require' => '作者不能为空',
        'id.require' => 'id不能为空',
        //......
    ];

    //验证场景
    protected $scene = [
        'add' => ['name'],
        'edit' => ['title','id'],
    ];

}